package com.ninechapters.modulemanager
{
	import mx.controls.Image;
	
	public class Module
	{
		private var _code:String;
		private var _title:String;
		private var _description:String;
		private var _examinable:Boolean;
		private var _openbook:Boolean;
		private var _examDate:String;
		private var _modularCredits:int;
		private var _prerequisite:Array = new Array;
		private var _preclusion:String;
		private var _workload:String;
		private var _remarks:String;
		private var _complete:Boolean;   
		
		//constructor
		public function Module(codeV:String, 
		titleV:String = "", 
		descriptionV:String = "",
		examinableV:Boolean = false, 
		openbookV:Boolean = false, 
		examDateV:String = "",
		mcV:int = 4, 
		preclusionV:String = "", 
		workloadV:String = "", 
		remarksV:String = "", 
		completeV:Boolean = false)
		{
			_code = codeV;
			_title = titleV;
		    _description = descriptionV;
			_examinable = examinableV;
			_openbook = openbookV;
			_examDate = examDateV;
			_modularCredits = mcV;
			_preclusion = preclusionV;
			_workload = workloadV;	
			_remarks = remarksV;
			_complete = completeV;
		}
			
		[Bindable]
		public function set code(value:String):void{
			_code = value;
		}
		public function get code():String{
			return _code;
		}
			
		[Bindable]
		public function set title(value:String):void{
			_title = value;
		}
		public function get title():String{
			return _title;
		}
			
		[Bindable]
		public function set description(value:String):void{
			_description = value;
		}
		public function get description():String{
			return _description;
		}
			
		[Bindable]
		public function set examinable(value:Boolean):void{
			_examinable = value;
		}
		public function get examinable():Boolean{
			return _examinable;
		}
			
		[Bindable]
		public function set openbook(value:Boolean):void{
			_openbook = value;
		}
		public function get openbook():Boolean{
			return _openbook;
		}
			
		[Bindable]
		public function set examDate(value:String):void{
			_examDate = value;
		}
		public function get examDate():String{
			return _examDate;
		}
			
		[Bindable]
		public function set mc(value:int):void{
			_modularCredits = value;
		}
		public function get mc():int{
			return _modularCredits;
		}
			
		[Bindable]
		public function set prerequisite(... args):void{
			for (var i:uint = 0; i < args.length; i++){
				_prerequisite.push(args[i]);
			}
		}
		public function get prerequisite():String{
			return _prerequisite.toString();
		}
			
		[Bindable]
		public function set preclusion(value:String):void{
			_preclusion = value;
		}
		public function get preclusion():String{
			return _preclusion;
		}
			
		[Bindable]
		public function set workload(value:String):void{
			_workload = value;
		}
		public function get workload():String{
			return _workload;
		}
			
		[Bindable]
		public function set remarks(value:String):void{
			_remarks = value;
		}
		public function get remarks():String{
			return _remarks;
		}
		
		[Bindable]
		public function set complete(value:Boolean):void{
			_complete = value;
		}
		public function get complete():Boolean{
			return _complete;
		}
		
		//chech whether this module is ready for bidding
		//check whether all the prerequisites are complete
		public function checkPrerequisite():Boolean{
			for each (var module:Module in _prerequisite){
				if(!module.complete){
					return false;
				}
			}
			return true;
		}
	}
}